//
//  YuYueOrderHeaderView.m
//  FD
//
//  Created by xiaofang wang on 2018/11/9.
//  Copyright © 2018年 ZhiYuan Network. All rights reserved.
//

#import "YuYueOrderHeaderView.h" 
#import "YuYueOrderYuYueMessageView.h" //预约信息view //h 160 + 2 + 5=  167
//总 h: 150 + 5 + 167 = 322


@interface YuYueOrderHeaderView()
/**div1*/
@property (nonatomic, strong) UIView *div1;
/**1。预约门店lb*/
@property (nonatomic, strong) UILabel *yuyueMenDiaLb;

@property (nonatomic, strong) UIView *div2;
/**1.地址*/
@property (nonatomic, strong) UIImageView *dizhiIV;
/**2-1 店铺名字*/
@property (nonatomic, strong) UILabel *shopNameLb;
/**2-2详细地址*/
@property (nonatomic, strong) UILabel *addressLb;

/**3-1div*/
@property (nonatomic, strong) UIView *div3;
/**时间icon*/
@property (nonatomic, strong) UIImageView *timeIv;
/**timeLb*/
@property (nonatomic, strong) UILabel *timeLb;
/**预约信息view(预约信息/联系人、联系电话、餐品信息)*/
@property (nonatomic, strong) YuYueOrderYuYueMessageView *yuyueMsgView;
@end
@implementation YuYueOrderHeaderView

#pragma mark - 一 init
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setupView];
        
        self.backgroundColor = kMainLightGrayColor;
    }
    return self;
}

- (void)setupView {
    [self addSubview:self.div1];
    [self.div1 addSubview:self.yuyueMenDiaLb];
    
    [self addSubview:self.div2];
    [self.div2 addSubview:self.dizhiIV];
    [self.div2 addSubview:self.shopNameLb];
    [self.div2 addSubview:self.addressLb];
    
    [self addSubview:self.div3];
    [self.div3 addSubview:self.timeIv];
    [self.div3 addSubview:self.timeLb];
    
    
    [self addSubview:self.yuyueMsgView]; // 11-23 加
}

#pragma mark - 二 layout
//30 + 60 + 40
- (void)layoutSubviews {
    [super layoutSubviews];
    [self.div1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.right.equalTo(self);
        make.height.mas_equalTo(30);
    }];
    
    [self.div2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self);
        make.top.equalTo(self.div1.mas_bottom).offset(1) ;//1pxx线
        make.height.mas_equalTo(80);
    }];
    
    [self.div3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self);
        make.top.equalTo(self.div2.mas_bottom).offset(1); //1px 线
        make.height.mas_equalTo(40);
    }];
    
    [self layoutDiv1];
    [self layoutDiv2];
    [self layoutDiv3];
    
    
    //11-23 预约信息 h:167 + 5
    [self.yuyueMsgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.div3.mas_bottom).offset(5);
        make.left.right.equalTo(self);
        make.height.mas_equalTo(167);
    }];
}

- (void)layoutDiv1 {
    [self.yuyueMenDiaLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.div1.mas_left).offset(15);
        make.size.mas_equalTo(CGSizeMake(200, 20));
        make.centerY.equalTo(self.div1.mas_centerY);
    }];
}
- (void)layoutDiv2 {
    [self.dizhiIV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.div2.mas_left).offset(15);
        make.size.mas_equalTo(CGSizeMake(15, 20));
        make.centerY.equalTo(self.div2.mas_centerY);
    }];
    [self.shopNameLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.div2.mas_top).offset(5);
        make.height.mas_equalTo(20);
        make.left.equalTo(self.dizhiIV.mas_right).offset(5);
        make.right.equalTo(self.div2.mas_right).offset(10);
    }];
    [self.addressLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.dizhiIV.mas_right).offset(5);
        make.top.equalTo(self.shopNameLb.mas_bottom).offset(2);
        make.right.equalTo(self.div2.mas_right).offset(-10);
        make.bottom.equalTo(self.div2.mas_bottom);
    }];
}

- (void)layoutDiv3 {
    [self.timeIv mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.div3.mas_left).offset(15);
        make.centerY.equalTo(self.div3.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(15, 15));
    }];
    
    [self.timeLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.timeIv.mas_right).offset(5);
        make.centerY.equalTo(self.div3.mas_centerY);
        make.height.mas_equalTo(22);
        make.right.equalTo(self.div3.mas_right).offset(10);
    }];
}

#pragma mark - 三 getter
//!!!!:1 div1
- (UIView *)div1 {
    if (!_div1) {
        _div1 = [UIView new];
        _div1.backgroundColor = [UIColor whiteColor];
    }
    return _div1;
}


//!!!!:2 div2
- (UIView *)div2 {
    if (!_div2) {
        _div2 = [UIView new];
        _div2.backgroundColor = [UIColor whiteColor];
    }
    return _div2;
}
- (UILabel *)yuyueMenDiaLb {
    if (!_yuyueMenDiaLb) {
        _yuyueMenDiaLb = [UILabel new];
        _yuyueMenDiaLb.text = NSLocalizedString(Order_ReverseShop, @"预约门店") ;
    }
    return _yuyueMenDiaLb;
}

- (UIImageView *)dizhiIV {
    if (!_dizhiIV) {
        _dizhiIV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"address"]];
    }
    return _dizhiIV;
}
- (UILabel *)shopNameLb {
    if (!_shopNameLb) {
        _shopNameLb = [UILabel new];
    }
    return _shopNameLb;
}
- (UILabel *)addressLb {
    if (!_addressLb) {
        _addressLb = [UILabel new];
        _addressLb.numberOfLines = 0;
//        _addressLb.font = [UIFont systemFontOfSize:14.0 *kScaleFit];
        _addressLb.textColor = [UIColor lightGrayColor];
    }
    return _addressLb;
}

//!!!!:3 div3
- (UIView *)div3 {
    if (!_div3) {
        _div3 = [UIView new];
        _div3.backgroundColor = [UIColor whiteColor];
    }
    return _div3;
}
- (UIImageView *)timeIv {
    if (!_timeIv) {
        _timeIv = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"time"]];
    }
    return _timeIv;
}
- (UILabel *)timeLb {
    if (!_timeLb) {
        _timeLb = [UILabel new];
    }
    return _timeLb;
}

//预约信息view
- (YuYueOrderYuYueMessageView *)yuyueMsgView {
    if (!_yuyueMsgView) {
        _yuyueMsgView = [[YuYueOrderYuYueMessageView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 167)];
    }
    return _yuyueMsgView;
}


#pragma mark - 四 赋值

- (void)updateShopName:(NSString *)shopName address:(NSString *)address timeStr:(NSString *)timeStr consignee:(NSString *)consignee phone:(NSString *)phone {
    self.shopNameLb.text = shopName;
    self.addressLb.text = address;
    self.timeLb.text = timeStr;
    
    self.yuyueMsgView.lianxiRenLb.text = consignee; //联系人
    self.yuyueMsgView.phoneLb.text = phone; //联系电话
}

@end
